﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using School.Entities;
using School.Accounting;

namespace School.Pages.Accounting
{
    public partial class ReturnVoucher : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((IQueryable<int>)Session["privilage"] != null)
            {
                var x = (IQueryable<int>)Session["privilage"];

                if (x.Contains(113) == true)
                {



                }
                else
                    Response.Redirect("../organization/no_privelege.aspx");
            }
            else
                Response.Redirect("../organization/no_privelege.aspx");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            var v = Voucher.GetVoucher(long.Parse(TxtVoucherNumber.Text));

            if (v != null)
            {
                List<ACC_Voucher> vs = new List<ACC_Voucher>();
                vs.Add(v);

                GridView1.DataSource = vs.Select(x => new { x.Number, x.Date, Expense_Name = x.ACC_Expense.Name, x.Value, Student_Number = x.TE_Student.RegistrationNumber, Student_Name = x.TE_Student.Ar_FirstName + " " + x.TE_Student.Ar_SecondName + " " + x.TE_Student.Ar_ThirdNmae + " " + x.TE_Student.Ar_FourthName });
                GridView1.DataBind();
                Panel1.Visible = true;
                LblNotFound.Visible = false;
            }
            else
            {
                LblNotFound.Visible = true;
                Panel1.Visible = false;
            }
        }
    }
}